package com.fmsz.xmly.application;

import android.app.Application;

import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.fmsz.xmly.callbacks.FindBroadHttpService;
import com.fmsz.xmly.callbacks.FindClassifyHttpService;
import com.fmsz.xmly.callbacks.HttpService;
import com.fmsz.xmly.callbacks.MyLocationListener;
import com.fmsz.xmly.callbacks.FindRecomHttpService;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2016/12/7.
 */

public class MyApplication extends Application {

    private final String BASE_URL = "http://live.ximalaya.com/";
    private HttpService service;


    @Override
    public void onCreate() {
        super.onCreate();
        initHttp();
    }

    //广播数据service
    public FindBroadHttpService getBroadService(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit.create(FindBroadHttpService.class);
    }
    //分类数据service
    public FindClassifyHttpService getClassifyService(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://mobile.ximalaya.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit.create(FindClassifyHttpService.class);
    }
    //获取发现-推荐的service
    public FindRecomHttpService getFindRecomService(String baseUrl){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit.create(FindRecomHttpService.class);
    }
    private void initHttp() {
        service = new Retrofit.Builder()
                .baseUrl("http://mobile.ximalaya.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(HttpService.class);
    }

    public HttpService getService() {
        return service;
    }

}
